package com.kedacom.demo.springrabbit.transaction;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TransactionClient {

	private static Logger logger = LoggerFactory.getLogger(TransactionClient.class);

	public static void main(String[] args) {
		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
				"/springrabbit/spring-rabbitmq-transaction-client.xml");
		MessageSender messageSender = context.getBean(MessageSender.class);

		try {
			messageSender.sendMessage();
		} catch (Exception e) {
			logger.error(e.getMessage());
		}

		try {
			messageSender.bussinessRollback();
		} catch (Exception e) {
			logger.error(e.getMessage());
		}

		try {
			messageSender.messageRollback();
		} catch (Exception e) {
			logger.error(e.getMessage());
		}

		try {
			messageSender.bussinessRollback2();
		} catch (Exception e) {
			logger.error(e.getMessage());
		}

		System.exit(1);
	}

}
